Quantcast
Viewing all 3131 articles
Browse latest View live

Unsupported font style when converting HTML to PDF

Hi I am having problem converting HTML string to PDF by using DOM approach.
Here's my sample code snippet.
license.SetLicense(lic_path);
string fullPath = "C:\\OutputFolder\\"
string emailBodyDetails = "<html><body><SPAN style=""FONT-FAMILY: Calibri, 'Segoe UI', Meiryo, 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', sans-serif; FONT-SIZE: 16px"">Content.</SPAN></body><html>";
using (FileStream fs = new FileStream(fullPath + "Output.html", FileMode.Create))
{
using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
{
w.WriteLine(emailBodyDetails);
}
fs.Close();
}
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(fullPath + "Output.html", new HtmlLoadOptions() { UseNewConversionEngine = true });
doc.Save(fullPath + "Output.pdf");

I am getting error during conversion, and I found out that the html font style Meiryo is causing it, as when I remove the style from the string, it works fine. May I know how can this font be included in my document conversion?

At the same time, can I know which font are not supported in Aspose and what can I do to ensure all types of fonts are supported because we are not able to control the style usage in html as those contents are coming in from emails.

PDF conversion - reference version 1.7

Hello, i'm searching for this information: Aspose PDF conversion - from every kind of Aspose supported original files, doing instruction document.save(pdf-file) generates PDF files compatible with Adobe PDF reference version 1.7 ?

Thank's

Aspose fails to create large files

I'm using Aspose.PDF to create a PDF from a directory of JPG files. When the total size of the JPG files is up to 200 MB or so, the file is create properly. However, if I add in 250MB of JPG files, the Aspose.Pdf.Generator.Pdf.Save() routine saves a file with zero bytes.

To be clear: with the very same code, running Save() with 200 MB (or even 215 MB) of JPG files creates a good file, but running Save() with 250MB (or even just 239MB) of JPG files results in a zero-byte file.

The code that I am using follows below. As an example, you can use the set of JPG files that I've uploaded here: https://www.dropbox.com/sh/a8iao16hpiw6n2k/AAA-sCsDnmj430k5jj1v2tKsa
There are 560 jpg files in the directory, 437KB each, for a total of 239MB. The files are all identical in content. If you run the code on these files, a zero-byte file results. However, if you delete 100 of the files and run the code on the remaining 460 files, a proper PDF file results.

Aspose.Pdf.License lic = new License();
lic.SetLicense("Aspose.Pdf.lic");
string curdir = System.Environment.CurrentDirectory;

Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

string[] files = Directory.GetFiles(curdir, "*.*");

if (files.Length == 0) {
Console.WriteLine("No files found!");
return;
}

for (int ifile = 0; ifile < files.Length; ifile++) {
Console.WriteLine("Adding image " + ifile + " out of " + files.Length);

  FileStream fs = new FileStream(files[ifile], FileMode.Open, FileAccess.Read);
  byte[] tmpBytes = new byte[fs.Length];
  fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));

  MemoryStream mystream = new MemoryStream(tmpBytes);
  Bitmap b = new Bitmap(mystream);
  Aspose.Pdf.Generator.Section sec2 = new Aspose.Pdf.Generator.Section(pdf1);

  // Set margins so image will fit
  sec2.PageInfo.Margin.Top = 0;
  sec2.PageInfo.Margin.Bottom = 0;
  sec2.PageInfo.Margin.Left = 0;
  sec2.PageInfo.Margin.Right = 0;
  sec2.PageInfo.PageWidth = (b.Width / b.HorizontalResolution) * 72;
  sec2.PageInfo.PageHeight = (b.Height / b.VerticalResolution) * 72;

  //Add the section in the sections collection of the Pdf document
  pdf1.Sections.Add(sec2);

  //Create an image object
  Aspose.Pdf.Generator.Image image2 = new Aspose.Pdf.Generator.Image(sec2);

  //Add the image into paragraphs collection of the section
  sec2.Paragraphs.Add(image2);
  image2.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

  //Set the ImageStream to the MemoryStream object
  image2.ImageInfo.ImageStream = mystream;

}

//Save the Pdf
pdf1.Save(curdir + "\\newfile.pdf");
Console.WriteLine("Done!");


PNG converted from PDF is being cropped

Hi,
We are using ASPose.pdf.dll version 9.0.0.0.  When we attempt to convert the attached PDF document into a PNG file, the image is cropped off on the right side, as you'll see in the attached PNG.

TextFragment -- change size

Once I change the text by setting the TextFragment.Text property.  Is there a way to change the width or height of the TextFragment?  The text being replaced may be a different word and the width may be shorter or longer than the original text.  I was doing the intellisense.  It says the

textFragment.Rectangle   // this is read only.
textFragment.Rectangle.Width  // this is read only
textFragment.Rectangle.Height // this is read only

I got runtime error when trying to set this property.

Enclosed is the file which I would like to replace.  For instance @TravelerName@ will be replaced with "Bart Simpson" and @Country@ will be replaced with "USA".

Thanks,
Alfred

Convert html in pdf,has a bug.

hello, this is my test code below.                       

   Pdf pdf = new Pdf();
   Section section = pdf.Sections.Add();          
   Text text = new Text("<span style='font-family: \"Segoe UI\"; background-color: rgb(242, 249, 255);'>TestRGBColor</span>");           
   text.IsHtmlTagSupported = true;           
   section.Paragraphs.Add(text);           
   pdf.Save(@"C:\\result.pdf");

The result can't display properly, and I find reason is use "SegoeUI" and "rgb color".I used the Aspose.Pdf for .NET 9.4.0 dll.Can you help me fixed the bug?
thank you very much                 

  

 

If the Bookmarks is not exist, Export Bookmarks To XML ( The error occurred)

 How to decide whether there really are bookmark involved?

 Document pdfDocument = new Document(ABC.pdf);//ABC.pdf does not contain bookmarks .

 if (pdfDocument.Outlines.Count>0 || pdfDocument.Outlines.First.Count > 0)//Outlines.Count | 1
   {
       try        
       {
              Aspose.Pdf.Facades.PdfBookmarkEditor bookmarkEditor = new Aspose.Pdf.Facades.PdfBookmarkEditor();
                           
             bookmarkEditor.BindPdf(pdfDocument);
              //Export bookmarks
                  
              bookmarkEditor.ExportBookmarksToXML(sOutpathFile);//The error occurred
                               
              }

              catch (Exception ex)
               {
                     MessageBox.Show(ex.Message); 
               }
}
else
{
//
......
}

Text not rearranged after ReplaceText

When I call the ReplaceText method from the PdfContentEditor the text in a paragraph is not re-arranged after the replacement is made. If the replacing text is smaller than the size of the place holder I am left with an empty space. If the replacing text is longer than the place holder, there is a text overlap. Moreover the font is also changed. 

Any ideas?

Aspose pdf 9.3.0 fails to render table

using latest 9.3.0 , attached pdf does not print correctly, the bottom table is all black.

How to convert Persian Or Arabic words ?

Hi

     I'm using Aspose.Pdf for exporting report to PDF. but report is in Arabic and when I download the generated PDF it's content is like "س ل م" and every word is separated, but it must be like "سلام". how can I solve this issue ?


my code for generating PDF :

public static void ExportReportToPdf(DTO.Report.Report report)
        {
            var pdfDocument = new Pdf();

            pdfDocument.HtmlInfo.CharSet = "UTF-8";

            pdfDocument.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.UseWhenImpossibleDetectFromContent;

            var pdfSection = pdfDocument.Sections.Add();

            pdfSection.TextInfo.FontEncoding = "UTF-8";

            pdfDocument.TextInfo.FontEncoding = "UTF-8";

            pdfSection.Paragraphs.Add(new Text(report.Title));

            pdfSection.Paragraphs.Add(new Text(report.DateTime.ToShortDateString()));

            var text = new Text(pdfSection, report.Description) {IsHtmlTagSupported = true};

            pdfSection.Paragraphs.Add(text);

            pdfDocument.Save(HttpContext.Current.Server.MapPath("~/Content/report/temp.pdf"));

}

PDF to TIF conversion results in a black square on page 1 of the output TIF

Dear Sir/Madam, I have had great success using Aspose for PDF to TIF conversion, but I found that a particular PDF document results in a TIF with a black square on page 1 of the output file, where the black square is not present on the original PDF. Unfortunately PDF document is confidential, and I cannot post it directly on the forum. I would be grateful if you could please assist and advise if there is a workaround for the black square issue.

HTML with multibyte characters don't convert to PDF properly

When I create a pdf document from html string, multibyte characters are missing in saved document,  see code below:

                    var pdf = new Aspose.Pdf.Generator.Pdf();
                    pdf.SetUnicode();
                    string html1 = " <div >TEST_中文文档资料_TEXT</div>";
                    pdf.ParseToPdf(html1);
                    //AsposePdfCreator.ConvertToWordDoc(pdf, html1, pdftype);
                    pdf.SetUnicode();
                    pdf.Save(@"c:\test2.pdf");

SetUnicode() does not help
I am using Aspose.pdf version 9.1
Am I doing somethisg wrong?
Thank you,
Alexei

Wrapping of Text when doing Search and Replace

Hello,

I am trying to replace text in PDF files using the following code.  The problem is that the text does not wrap if the line becomes too long due to the replacement text.  Is there a way to handle this?  I have attached sample input and output files to illustrate the problem.

            Document pdfDocument = new Document("input.pdf");
        TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("rinse");
        pdfDocument.Pages.Accept(textFragmentAbsorber);

        TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

        foreach (TextFragment textFragment in textFragmentCollection)
        {
            textFragment.Text = "LONG REPLACEMENT TEXT";
        }

        pdfDocument.Save("output.pdf");



- Sumit

Form Fields not filled in when converting PDF to JPG

When I convert a PDF to JPG, the form fields are not filled out.  When I look at the same PDF in Adobe reader the fields are filled out correctly.  (I have attached images of both)

Here is my code:

Dim doc As New Aspose.Pdf.Document(fileName)Using memStream As New IO.MemoryStream()'create Resolution objectDim resolution As New Aspose.Pdf.Devices.Resolution(300)'create JPEG device with specified attributes (Width, Height, Resolution, Quality)'Quality [0-100], 100 is MaximumDim jpegDevice As New Aspose.Pdf.Devices.JpegDevice(resolution, 100)'convert a particular page and save the image to stream
	jpegDevice.Process(doc.Pages(page), memStream) 
Return memStream.ToArray()End Using

Exception being thrown using FillImageField

In the old version (AsposePdfKit) I use to be able to set a Digital Signature field in PDF to an image.

Example:

Where pdfLetter is a Form object:

pdfLetter.FillImageField(fieldName, signatureImageFilename);

 

However the above is now throwing an error: Field name 'Signature' doesn't represent valid text or button field. Field name 'Signature' doesn't represent valid text or button field.

FileVersion 7.3.0.0

Production Version: 2012.08.28

 

 


Large MultiPage PDF generated using Aspose PDF 7.2

Hi,

I have been using Aspose 7.2 PDF for .Net 4 framework. I have a bunch of images (approx 55 pages) which i will be converting to PDF format. When it gets converted to MultiPage PDF, its file size becomes significantly Large. 

For example : For sample attached image, when the same image used to create 55 MultiPage PDF, it would create larger Multipage PDF.

Please let us know how can we achieve optimum quality along with Minimum size.

link to a file that is already attached (embedded) to a pdf

Using Aspose, I have already attached multiple PDFs to my main PDF.  What I am trying to do is to create a link in the main PDF to one of those attached PDFs.

Here's the pseudo-code:

string[] PDFarry; //already pre-populated with a list of file paths to attach
foreach (string PDF in PDFarry)
                {
Aspose.Pdf.Text.TextFragmentAbsorber textFragmentAbsorber = new Aspose.Pdf.Text.TextFragmentAbsorber(curFileName);
pdfDocument.Pages.Accept(textFragmentAbsorber);
Aspose.Pdf.Text.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (Aspose.Pdf.Text.TextFragment textFragment in textFragmentCollection)
                        {
                            foreach (Aspose.Pdf.Text.TextSegment textSegment in textFragment.Segments)
                            {
      int curPage = textFragment.Page.Number;
      Page curPageNum = pdfDocument.Pages[curPage];
      Aspose.Pdf.Rectangle recTangle = textFragment.Rectangle;
      string attPath = PDF;
      editor.CreateFileAttachment(recTangle.ToRect(), "", attPath, curPage, "Paperclip");
                              
                            }
                        }

This code runs through the array of paths, and for each path it searches for the "filename.pdf" part of the path within the main PDF (the filename is already in the main PDF) All of that works thus far.  But, instead of the paperclip, I am trying to make a rectangle around the text and basically make an "invisible button" to go over each of the filenames in the main PDF. 

So, I guess that's the bottom line. I want to draw a rectangle around some text and then turn that rectangle into a link that will open an attached PDF.


Adding an hyperlink to open the attachment

Hi,

I have a requirement like reading an existing PDF file and adding few attachments to that. At the same time I need to provide a hyperlink called "Click here to open the attachment1" at the end of the document.

What is the best way to do this?

Setting the Border on specific cells within Table

Hello, I'm using Aspose.Pdf.Generator version 8.3.1.0 and I'm trying to change the border on certain cells within my Table such that when a specific value is encountered, I want to set the top border to a blue line. However, this is not working properly as only the top border of the table is changing whereas I want the border on the individual cells to be changed . Here is my code:

using Aspose.Pdf.Generator;
     dataTable.ImportDataTable(ConstructDummyDataTable(), false, 0,0);

 foreach (Row row in dataTable.Rows)
            {
                string value = row.Cells[Constants.ICDDESCRIPTION_IDX].GetText();
                if (value.Equals("Total"))
                {
                    GraphInfo line = new GraphInfo();
                    line.DashLengthInBlack = 2.5F;
                    line.LineWidth = 2.0F;
                    line.IsAddedArrowAtEnd = true;
                    line.Color = new Color("Blue");

                    BorderInfo bdrTotalCell = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.Top, line);

                    Aspose.Pdf.Generator.TextInfo txtBoldInfo = new Aspose.Pdf.Generator.TextInfo();
                    txtBoldInfo.IsTrueTypeFontBold = true;
                    txtBoldInfo.FontSize = 10F;
                    txtBoldInfo.FontName = "Calibri";
                    row.DefaultCellTextInfo = txtBoldInfo;

                    row.Cells[Constants.LOCALINPUT_IDX].Border = bdrTotalCell;
                    row.Cells[Constants.USADJ_IDX].Border = bdrTotalCell;
                    row.Cells[Constants.USGAAP_IDX].Border = bdrTotalCell;
                }
            }

Please note that for some reason the borders on the individual cells are not appearning. Please help. I've been working over the thanksgiving holiday to get this to work properly and I've tried everything.

Thanks.

Page Orientation Settings for com.aspose.pdf.Document

Hi,

Is there anyway to setup the page orientation for PDF document. In my requirement, i am not creating any new PDF document. I am loading the existing PDF document into com.aspose.pdf.Document object to apply pagesetup

Regards

Viewing all 3131 articles
Browse latest View live