/// <summary> /// Конструктор конкретного продукта (документа) в формате PDF. /// </summary> public PDFText() { // Добавление новой страницы в PDF документ с разрешением 500х500px. pdfData.addPage(500, 500); //Устанавка шрифта документа по умолчанию. currentPDFfont = pdfData.getFontReference(pdfFont.getFontName(predefinedFont.csHelvetica)); //Создание текстового елемента (в подключеной библиотеке sharpPDF это контейнер для символьных данных, аналогично блоку текста/f,pfwf). currentCharElem = new textElement(String.Empty, 14, currentPDFfont, 30, lastElemPostionY); //Устанавка Y-координаты последнего символа в документе. lastElemPostionY = currentCharElem.coordY; }
private double addText(pdfPage page, string text, double xPosInMM, double yPosInMM, double maxXSizeInMM, pdfAbstractFont writeFont, int writeFontSize) { int maxXSizeInPoints = (int)(maxXSizeInMM / conversionPixelsToMM); while (writeFont.getWordWidth(text, writeFontSize) > maxXSizeInPoints) { text = text.Substring(0, text.Length - 1); } int xInPoints = (int)(xPosInMM / conversionPixelsToMM); int yInPoints = page.height - (int)(yPosInMM / conversionPixelsToMM); page.addText(text, xInPoints, yInPoints, writeFont, writeFontSize); double newY = (double)(page.height - yInPoints + writeFontSize); newY = conversionPixelsToMM * newY; return(newY); }
private double addText(pdfPage page, string text, double xPosInMM, double yPosInMM, double maxXSizeInMM, pdfAbstractFont writeFont, int writeFontSize) { int maxXSizeInPoints = (int)(maxXSizeInMM/conversionPixelsToMM); while (writeFont.getWordWidth(text, writeFontSize) > maxXSizeInPoints) { text = text.Substring(0, text.Length-1); } int xInPoints = (int)(xPosInMM/conversionPixelsToMM); int yInPoints = page.height - (int)(yPosInMM/conversionPixelsToMM); page.addText(text,xInPoints,yInPoints,writeFont,writeFontSize); double newY = (double)(page.height-yInPoints+writeFontSize); newY = conversionPixelsToMM*newY; return newY; }
private double addText(pdfPage page, string text, double xPosInMM, double yPosInMM, pdfAbstractFont writeFont, int writeFontSize) { if (page == null) { page = getNewPage(ref yPosInMM); } int xInPoints = (int)(xPosInMM / conversionPixelsToMM); int yInPoints = page.height - (int)(yPosInMM / conversionPixelsToMM); page.addText(text, xInPoints, yInPoints, writeFont, writeFontSize); double newY = (double)(page.height - yInPoints + writeFontSize); newY = conversionPixelsToMM * newY; return(newY); }
private double addText(pdfPage page, string text, double xPosInMM, double yPosInMM, pdfAbstractFont writeFont, int writeFontSize) { if (page == null) page = getNewPage(ref yPosInMM); int xInPoints = (int)(xPosInMM/conversionPixelsToMM); int yInPoints = page.height - (int)(yPosInMM/conversionPixelsToMM); page.addText(text,xInPoints,yInPoints,writeFont,writeFontSize); double newY = (double)(page.height-yInPoints+writeFontSize); newY = conversionPixelsToMM*newY; return newY; }