Quantcast
Channel: Aspose.Pdf Product Family
Viewing all 3131 articles
Browse latest View live

HtmlLoadOptions for HtmlFragment

$
0
0
I have snippets of HTML that I want to add to my pdf. The html Snippets have images embeded as base64 string in the html itself.
When I add the html snippet as HTMLfragement to  page it works fine, but when the images are big it cuts of the image.. Following is the code I am doing
row = table.getRows().add();
c = row.getCells().add();
HtmlFragment html = new HtmlFragment(i.getComments());
c.getParagraphs().add(html);But when I do the same html snippet with loadoptions and save as
pdf it looks fine.
Document htmlDoc = new Document(new ByteArrayInputStream(i.getComments().getBytes(StandardCharsets.UTF_8)),
htmlLoadOptions);
htmlDoc.save(
"D:/work/temp_xxx.pdf");Is there a way for me when creating a HTMLFragment, to set the size like loadOptions ? If not is their a workaround ?

Not all PDF Form Fields Being Returned

$
0
0
I am trying to use Aspose.Pdf to enumerate the form fields in a PDF.

I am using Aspose.Pdf version 2016.08.02 (11.9.0.0). I start by opening the PDF:

Dim document As New Aspose.Pdf.Document(Server.MapPath("~/App_Data/88.pdf"))


I then enumerate the fields in document.Form. For each field, I call a method that displays the information:

For Each fld As Aspose.Pdf.Forms.Field In document.Form
    DisplayField(fld)
Next


In the DisplayField method I see if it's a group and, if so, recurse into the children of the group. Otherwise I just display the form field details (this is an ASP.NET application).

Private Sub DisplayField(fld As Aspose.Pdf.Forms.Field)
    If fld.IsGroup Then
        For Each childFld As Aspose.Pdf.Forms.Field In fld
            DisplayField(childFld)
        Next
    Else
        lblOutput.Text &= String.Format("<p>Name={0}, PartialName={1}, FullName={2}, Required={3}, ReadOnly={4}, Value={5}</p>",
                                        fld.Name,
                                        fld.PartialName,
                                        fld.FullName,
                                        fld.Required,
                                        fld.ReadOnly,
                                        fld.Value)
    End If
End Sub


The issue, though, is that it only enumerates through a small number of the form fields in the PDF. There are many other (on the same page and other pages) that aren't getting displayed. For instance, the attached PDF has 32 form fields. But when I use the above code, Aspose.Pdf returns only 4 form fields.

Here's the output displayed in the web page. You can see I only get 4 form fields:

Name=, PartialName=box1 pg1, FullName=box1 pg1, Required=False, ReadOnly=False, Value=Yes

Name=, PartialName=box2 pg1, FullName=box2 pg1, Required=False, ReadOnly=False, Value=

Name=, PartialName=box3 pg1, FullName=box3 pg1, Required=False, ReadOnly=False, Value=

Name=, PartialName=fname1 pg1, FullName=fname1 pg1, Required=False, ReadOnly=False, Value=The Village Family Services


How do I get ALL form fields?

What's interesting, it that if I debug and view in the Immediate Window the following:

document.Form.Count

I get back 32 (as to be expected). 

But if I do:

document.Form.Fields.Count

I get back 4, which would explain why it only shows four form fields. When I step through the code I see that the loop is only iterated through 4 times. So what gives? How do I loop through all 32 form fields?

Convert HTML to PDF - change font, margin and size

$
0
0
I am converting an hml string to PDF. the issues are:

1) ignoring margins when printing 
2) ignoring font size
3) need to set to legal size paper

code

string pageSource="<html>
<head>
</head>
<body>
    REPORT NO. xxxxxxx                                                Company Name                                                                                    RUN DATE 02/01/17       PAGE    1<br />PROG. ID   xxxxxx                                                   XXXXX/XXXX XXX XXXXXXXXXXX XXXXXXX Statement                                                                         RUN TIME 03:59:11<br />                                                                    For Month Ending JAN 2017<br /><br />XXXXXXXXXXX Company BCAG XXXXXXXXXXX COMPANY, LTD.<br />XXXXXXXXXXX ID No.  I0001<br />XXXXXX No.  207139/XXXXX UNIVERSE<br /><br />                                                                XXXXX_XXXX CARE NEW XXX                    XXXXX_XXXX CARE USED XXX                         NON-XXXXX XXX                                Grand Total<br />                                                            Current  Calendar Year      Inception       Current  Calendar Year      Inception       Current  Calendar Year      Inception       Current  Calendar Year      Inception<br />                                                             Month       Todate           Todate         Month       Todate           Todate         Month       Todate           Todate         Month       Todate           Todate<br /><br />A. PREMIUM<br />  1. XXXX XXXXXXX                                        10,403.25      10,403.25      10,403.25      3,546.00       3,546.00       3,546.00           .00            .00            .00     13,949.25      13,949.25      13,949.25<br />  2. XXXXXXXX XXXX - CANC XXX                                   .00            .00            .00           .00            .00            .00           .00            .00            .00           .00            .00            .00<br />  3. NET XXXXXXX PREMIUM                                  10,403.25      10,403.25      10,403.25      3,546.00       3,546.00       3,546.00           .00            .00            .00     13,949.25      13,949.25      13,949.25<br /><br />B. XXXXXX XXXX                                               520.16         520.16         520.16        177.30         177.30         177.30           .00            .00            .00        697.46         697.46         697.46<br /><br />C. XXXX XXXXX                                                  .00            .00            .00           .00            .00            .00           .00            .00            .00           .00            .00            .00<br /><br />D. XXXXXXXXXX (A3-B-C)=D                                 9,883.09       9,883.09       9,883.09      3,368.70       3,368.70       3,368.70           .00            .00            .00     13,251.79      13,251.79      13,251.79<br /><br />E. XXXXXXXXXXXXXXXXXXXXX<br />  1. UNEARNED PREMIUM                                           .00            .00            .00           .00            .00            .00           .00            .00            .00           .00            .00            .00<br />  2. INCURRED BUT NOT REPORTED                                  .00            .00            .00           .00            .00            .00           .00            .00            .00           .00            .00            .00<br />  3. XXXXXXXXXXXXXXXXXXXXXX                        .00            .00            .00           .00            .00            .00           .00            .00            .00           .00            .00            .00<br /><br />F. XXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />  1. UNEARNED PREMIUM                                     10,399.58      10,399.58      10,399.58      3,506.59       3,506.59       3,506.59           .00            .00            .00     13,906.17      13,906.17      13,906.17<br />  2. INCURRED BUT NOT REPORTED                                 1.12           1.12           1.12         11.84          11.84          11.84           .00            .00            .00         12.96          12.96          12.96<br />  3. ENDING UNEARNED PREMIUM AND IBNR                     10,400.70      10,400.70      10,400.70      3,518.43       3,518.43       3,518.43           .00            .00            .00     13,919.13      13,919.13      13,919.13<br /><br />G. AMORTIZED CEDING FEE<br />  1. XXXXXXXXXXXXXXXXXXXXXXXX                              .00            .00            .00           .00            .00            .00           .00            .00            .00           .00            .00            .00<br />  2. ENDING DEFERRED CEDING FEE                              519.83         519.83         519.83        175.31         175.31         175.31           .00            .00            .00        695.14       1,214.97         695.14<br />  3. XXXXXXXXX (B+G1-G2)                             .33            .33            .33          1.99           1.99           1.99           .00            .00            .00          2.32           2.32           2.32<br /><br />H. XXXXXXXXXXXXXXXXXX/(XXXXX)(A3+E3-F3)-(C+G3)=H          2.22           2.22           2.22         25.58          25.58          25.58           .00            .00            .00         27.80          27.80          27.80<br /><br />I. LOSS RATIOS<br />  1. XXXXXXXX(C+F2-E2)                                 1.12           1.12           1.12         11.84          11.84          11.84           .00            .00            .00         12.96          12.96          12.96<br />  2. EARNED PREMIUMS (A3+E3-F3)                                2.55           2.55           2.55         27.57          27.57          27.57           .00            .00            .00         30.12          30.12          30.12<br /><br />J. XXXXXXXXXX<br />  1. XXXXXX                                                      17             17             17             6              6              6             0              0              0            23             23             23<br />  2.XXXXX                                                    0              0              0             0              0              0             0              0              0             0              0              0<br />  3. NET                                                         17             17             17             6              6              6             0              0              0            23             23             23<br /><br />
</body>
</html> "

     Aspose.Pdf.Document pdf;
                
                Aspose.Pdf.HtmlLoadOptions htmlLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
                MemoryStream outputstream = new MemoryStream();
                htmlLoadOptions.InputEncoding = "UTF-8";
                htmlLoadOptions.PageInfo.Margin.Left = 0;
                htmlLoadOptions.PageInfo.Margin.Right = 0;
                htmlLoadOptions.PageInfo.Margin.Top = 0;
                htmlLoadOptions.PageInfo.Margin.Bottom = 0;
                htmlLoadOptions.PageInfo.IsLandscape = true;
                htmlLoadOptions.PageInfo.DefaultTextState.FontSize= 7;
                       

                using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(pageSource)))
                {
                    pdf = new Aspose.Pdf.Document(stream, htmlLoadOptions); 

                }

                Aspose.Pdf.Facades.PdfFileEditor pfe = new Aspose.Pdf.Facades.PdfFileEditor();
                pfe.ResizeContents(pdf, Aspose.Pdf.Facades.PdfFileEditor.ContentsResizeParameters.PageResize(17 * 72, 11 * 72));



                pdf.Save(outputstream);
                byte[] bytes = outputstream.GetBuffer();
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "xxx_List.pdf"));
                HttpContext.Current.Response.ContentType = "application/pdf";
                HttpContext.Current.Response.BinaryWrite(bytes);
                //  render the htmlwriter into the response                    
                HttpContext.Current.Response.End();

Print - fill paper

$
0
0
I have tried to set margins but the resulting pdf is not printed to edge of paper. Please let me know which exact properties to use in c# or vb.NET.

How to add Tooltip to a cell using ASPOSE API

$
0
0
Hi,

I have an FTL template file which we use to generate a PDF. i am trying to add a tooltip text to this template file using ASPOSE API. 

Can someone please help how this can be done?

Here is a sample of my file - 

<Table ColumnWidth="100%"><row><cell><segment> Hi How are you..!  </segment></cell></row></Table>

Font on Field Not Updating

$
0
0
Hello!

I'm trying to use a TrueType font  on a field in a PDF. The font is embedded in the document and I can use the font for text, but the field seems to be ignoring the font.

Apose version is 17.6.0

// Here I create my font object
Font steveFont = Aspose.Pdf.Text.FontRepository.OpenFont(@"C:\Work\TF_DEV\WOW.EAPP.Common\1_DEVL\WebServices\EAppServices\STEVE.TTF");
steveFont.IsEmbedded = true;

// Here I create my appearance object
var steveAppearance = new DefaultAppearance(steveFont, fontSize, System.Drawing.Color.DarkBlue);
steveAppearance.FontName = "SteveHandwriting";


// Later, I call this method to build the TextBoxField and pass steveAppearance to this method.
private TextBoxField CreatePiSigTextBox(Document pdfDocument, DefaultAppearance appearance)
{
    if (log.IsDebugEnabled) log.DebugFormat(CultureInfo.InstalledUICulture, $"CreatePiSigTextBox called");
    TextBoxField piSigTextBox = new TextBoxField(pdfDocument.Pages[page], GenerateSigRectangle(signatureCoordinates.piSigXpos, signatureCoordinates.piSigYpos));
    piSigTextBox.HorizontalAlignment = HorizontalAlignment.Left;
    piSigTextBox.PartialName = "SIG_X_APPCNT";
    piSigTextBox.DefaultAppearance = appearance;
    return piSigTextBox;
}

We tried some other fonts, too, but we can't see to get the field to change. Any suggestions?

Thanks!

Aspose.Pdf.Generator.Pdf

$
0
0
I just upgraded to the latest version 17.6 from version 17.4, and it appears that in the last version 17.5 Aspose.Pdf.Generator.Pdf was removed.

What are we supposed to use to convert an image to a pdf now?

Update Hyperlinks in PDF - It is very urgent

$
0
0
Hi

I need to replace a hyperlink (text and url) in a pdf document, I tried the following code

   foreach (Aspose.Pdf.Page page in document.Pages)            {                // Get the link annotations from particular page                Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationSelector selector = new Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationSelector(new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial));                page.Accept(selector);                // Create list holding all the links                System.Collections.IList list = selector.Selected;                // Iterate through invidiaul item inside list                foreach (Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation a in list)
                {
string url = (a.Action as Aspose.Pdf.InteractiveFeatures.GoToURIAction).URI;                    if (url == "https://www.aspose.com/community/forums/addpost.aspx?ForumID=20")                    {                        Console.WriteLine("<br />Destination: " + (a.Action as Aspose.Pdf.InteractiveFeatures.GoToURIAction).URI + "<br />");
                        a.Action = new GoToURIAction(@"www.google.com");
break;
}
}
}		
   document.Save(filename1);

It changes the URL of the hyperlink but not the text. How to change the display text, I tried two methods
simple text replace which replaced but I can see a long underline after the hyperlink text
then I tried the following...
// a is retrieved from the above code ***
                        TextFragmentAbsorber ta = new TextFragmentAbsorber();                        Aspose.Pdf.Rectangle rect = a.Rect;                        rect.LLX -= 10;                        rect.LLY -= 10;                        rect.URX += 10;                        rect.URY += 10;                        ta.TextSearchOptions = new TextSearchOptions(rect);                        ta.Visit(document.page);  // page is coming from the above logic                        // Change color and text.                        foreach (TextFragment tf in ta.TextFragments)                        {                            tf.TextState.ForegroundColor = Aspose.Pdf.Color.Red;                            tf.Text = "Click Here";                        }                        break;

but this replaces  the text but many times as attached(after.img), "Click Here" is appeared many times in the same sentence and the hyperlink format (underline and blue colored text are not disappearing from the previous long URL)
It would be helpful if you give me some suggestion to resolve this issue ,its bit urgent.
otherwise, what is the best way to delete the existing hyperlinks (text and url) and add a new one at the same location? can I have the sample code ?

Please check the attached images.
Regards
Sam.



Convert PDF to Excel with all images found in PDF document?

$
0
0
Hi Aspose team,

I would like to convert PDF to Excel with following code:

               Document document = new Document("SomeDocument.pdf");
                ExcelSaveOptions saveOptions = new ExcelSaveOptions();
                saveOptions.InsertBlankColumnAtFirst = false;
                saveOptions.MinimizeTheNumberOfWorksheets = true;
                document.Save("NewDocument.xls", saveOptions);

It created XLS document but I do not have a single images from PDF document. Only text is exported.

What would you recommend to be used to convert PDF to Excel where images in PDF document are also included?

Thx

java.awt.HeadlessException thrown when converting HTML to PDF

$
0
0
Updating to Aspose PDF for Java 17.3.0 and higher throws an exception while trying to convert an HTML file to PDF under headless environments:

java.awt.HeadlessException
at sun.awt.HeadlessToolkit.getScreenSize(HeadlessToolkit.java:284)
at com.aspose.pdf.internal.p340.z5.<init>(Unknown Source)
at com.aspose.pdf.internal.p312.z5.m1(Unknown Source)
at com.aspose.pdf.internal.p296.z3.m1(Unknown Source)
at com.aspose.pdf.internal.p312.z5.<init>(Unknown Source)
at com.aspose.pdf.internal.p296.z3.<init>(Unknown Source)
at com.aspose.pdf.z88.m1(Unknown Source)
at com.aspose.pdf.z88.m1(Unknown Source)
at com.aspose.pdf.z88.m1(Unknown Source)
at com.aspose.pdf.z88.m1(Unknown Source)
at com.aspose.pdf.ADocument.m1(Unknown Source)
at com.aspose.pdf.ADocument.<init>(Unknown Source)
at com.aspose.pdf.Document.<init>(Unknown Source)

I'm attaching a maven project with a test case to demonstrate the problem.

Password rules for encrypting files

$
0
0
My application encrypts PDF files with line:
EncryptFile(userPassword, ownerPassword, DocumentPrivilege.AllowAll, KeySize.x128, Algorithm.AES)

I got exception 
Exception: System.IO.IOException: Bad password!: v5.6.0.0
   at Aspose.Pdf.Kit.PdfFileSecurity.EncryptFile

The password looks like that ABC2EFG2016 .

Is that because the password format is not good? What are the rules on which password is valid?

Update demos and showcases

$
0
0
Your demos and showcases need to be updated to reflect your recent changes.

https://github.com/aspose-pdf/Aspose.Pdf-for-.NET

Multiline Aspose.Pdf.Forms.RichTextBoxField Line-Height

$
0
0

Could you please provide samples of a supported RichTextValue that will allow setting the line-height for each line of a multiline Aspose.Pdf.Forms.RichTextBoxField?

I’ve tested with the Xml value below, but it causes errors when opening the Pdf.

“An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.”

<?xml version=\"1.0\"?><body xfa:APIVersion=\"Acroform:2.7.0.0\" xfa:spec=\"2.1\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\"><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">1</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">2</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">3</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">4</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">5</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">6</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">7</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">8</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">9</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">10</p></body>

 

Thanks for your help...

The actual PDF got scattered when we upload the PDF in PDF canvas

$
0
0
Hi,

We are still approaching for "PDFNET-42582" resolution. We did not get the any solution from Aspose regarding this as we had already purchase licence the order number is :170307115621, also we need to move the functionality to the production. We already miss the dead line. Please refer the link below which we posted earlier almost quarter back.

https://www.aspose.com/community/forums/thread/835824/ury-and-urx-component-interpreted-wrong-for-some-pdf-files-and-shapes-push-on-wrong-position-after-s.aspx

We could not able to reply the same post.

Regard's
Sujit

Aspose.Pdf convert PDF to SVG, save to MemoryStream not supported.

$
0
0
Hello, is it possible to convert a PDF file to SVG and save output to MemoryStream? I need this feature to be available if our organization is to purchase your products.

   var outputStream = new MemoryStream();

 var doc = new Aspose.Pdf.Document(inputStream);

        var saveOptions = new Aspose.Pdf.SvgSaveOptions()
        {
            CompressOutputToZipArchive = false
        };

        doc.Save(outputStream, saveOptions); 

Exception while executing function: Functions.FileConverterHttpSVG. Aspose.Pdf: Save a document to a SVG stream is not supported. Please save to a file instead.

Regarding table of content using aspose.pdf licence version

$
0
0
Hi support team,


We are using Aspose.PDF to convert pdf file to doc format. we are using licence version.
we are creating PDF file using DITA OT tool. 
Now we need to convert this PDF file into Doc format. Aspose is converting this into doc format but not in a proper way, the issue we are facing is Table of Content (TOC) of our pdf is not getting reflected on Doc file.
 
So requesting you to please look into this as high priority.
My contact number is +91 9604432049 
my email address : Srinivas.Gumma@e-zest.in





default padding for htmlfragment

$
0
0
Hi,

I am trying to insert html fragment in a table. It seems HtmlFragment element is adding default top padding to the contents. I am trying to remove the padding. But it is not working.
Can you please look into this.

I tried all the following options:

HtmlFragment fgmt = new HtmlFragment("<div style=\"background-color:red;padding-top:0;\">test</div>");

HtmlFragment fgmt = new HtmlFragment("<span style=\"padding-top:1pt;background-color:red;\">test</span>");

HtmlFragment fgmt = new HtmlFragment("<p style=\"padding-top:1pt;background-color:red;\">test</p>");

HtmlFragment fgmt = new HtmlFragment("<p style=\"padding-top:1px;background-color:red;\">test</p>");

Thanks
Mamatha


Knowing the Text para length

$
0
0
Hi,

I have a pdf document where I have already drawn a Text para. After that I want to draw a floating box; but for drawing a floating box, I need to know the number of lines that text has spanned.

Is there any way to know the number of lines or the height of the Text.

I have tried the following options, but they all return -1 or 0.0 (default values) I guess.

((Text)paragraph).getHeight() // returns -1
((Text)paragraph).getTextWidth() // returns 0.0. If I can get the width, I can say the number of lines by comparing to pdf width.

Thanks!!

Conversion PDF to DOC is not correct

$
0
0
Hi,
i'm trying Aspose PDF for Java because i want integrate it on my swing application but the conversion from PDF to DOC/ODT is not good for me.
I Attach a original PDF and correspondents DOC and DOCX.

Thank's

Rendering problem in Indian Language

$
0
0
Hi,
I was trying Aspose PDF Java  for replacing text with an Local Language text.
I encountered some issues.
Issue1. The rendering of Unicode Hindi characters are not proper.


Original Text was : Hello World

Changed text should be : हेलो विश्व

but the text displayed was not displayed correctly .Please refer the PDF attched.

Issue 2:  I applied font on one text stream where as the new font was applied on all other text and it was not readable(Blocks formation)  Refer PDF attached

Let me know if you need any other information from my side.




Viewing all 3131 articles
Browse latest View live