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

Font not found in linux

$
0
0
Hi there,

I am using pdf 11.1.0 to convert pdf files to html.

I got an exception in linux

class com.aspose.pdf.exceptions.FontNotFoundException: Font Helvetica can not found.
com.aspose.pdf.internal.p53.z29.m27(Unknown Source)
com.aspose.pdf.internal.p42.z1.m1(Unknown Source)
com.aspose.pdf.internal.p42.z3.m1(Unknown Source)
com.aspose.pdf.internal.p32.z7.m3(Unknown Source)
com.aspose.pdf.internal.p32.z7.m4(Unknown Source)
com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
com.aspose.pdf.internal.p32.z7.m2(Unknown Source)
com.aspose.pdf.ApsUsingConverter.m1(Unknown Source)
com.aspose.pdf.z37.m1(Unknown Source)
com.aspose.pdf.ADocument.save(Unknown Source)
com.aspose.pdf.Document.save(Unknown Source)

And my code would be like this:

Document pdf = new Document("custom/input/pdf/Redis.pdf");
HtmlSaveOptions htmlSaveOps = new HtmlSaveOptions();
pdf.save("custom/output/pdf/Redis.html", htmlSaveOps);


this pdf should be in the attachement.

Please take a look and help me solve this problem, thanks :)

Table row in new pdf page using Aspose.Pdf.generator

$
0
0
Hi, Can we have similar property tableRow.IsInNewPage in Aspose.Pdf.Generator tables?

BUG: System.IO.EndOfStreamException when converting PDF to DOC

$
0
0
Hello.

I am trying to convert to DOC the attached PDF and Aspose.Pdf.Document.Save throws System.IO.EndOfStreamException.
I am using Aspose.PDF 11.2 trial version.


Stream PdfToWordAspose(Stream pdf)
{
//load the PDF
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(pdf);

MemoryStream docStream = new MemoryStream();
Aspose.Pdf.DocSaveOptions saveOptions = new Aspose.Pdf.DocSaveOptions();
saveOptions.Format = Aspose.Pdf.DocSaveOptions.DocFormat.Doc;
saveOptions.Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.Flow;
saveOptions.RecognizeBullets = true;

pdfDoc.Save(docStream, saveOptions);
docStream.Position = 0;

return docStream;
}




Regards.

Need help in document conversion

$
0
0
Hi Team,
We are planning to buy Apsose pdf for .net and we are in the process of evaluating the same.We have a problem while converting the PDF file to different formats.

The issue is we have to read and save the converted file using stream as we are not allowed to store the saved or uploaded file in the server.As i have checked your website it has code only to read from a physical PDF file and save the other formats physically.Can you please help us out by providing the code for reading and saving using stream.


Looking forward for your reply.



Thanks,
Navaneethan V

PDF Form - File corrupted

$
0
0

Good Morning,

We have a problem with the generation PDF Form File,

The first and second PDF File have a error (FileCorrupted1.pdf and FileCorrupted2.pdf)

This file is correct(Correct.pdf), but the three file have been generated from the same template(Template.pdf).

The problem is not present all the time, it's weird.

Do you any idea for our problem?

This is our code Aspose 10.4, the same code with Aspose 8.2 is all the time correct.

'Get Template
objStrmFichPDFEntre = New MemoryStream(_bytFichPDFBin)
objForm = New Aspose.Pdf.Facades.Form(objStrmFichPDFEntre)

'Fill Fields
objForm.BindPdf(objStrmFichPDFEntre)
objForm.FillField("TxtNomImprimante","\\IMPPRODQUE2\Q800")
objForm.FillField("TxtNomDocument","RBI_CRF5_26799666")
objForm.FillField("TxtLot","1 de 1")
objForm.FillField("TxtExpediteur","BJE5")
objForm.FillField("TxtDepot","B280")
objForm.FillField("TxtPage","12")
objForm.FillField("TxtDate","2015-09-24 13:54:26")
objForm.FillField("TxtProcessusManutention","Processus 1 (nombre de page(s): 12)")

objForm.FlattenAllFields()

objStrmFichPDFSorti = New MemoryStream
objForm.Save(objStrmFichPDFSorti)

Thank you

Extract each field from PDF one by one

$
0
0
Hi team,

Please check the attached document. It contains a lot of information about employees that we would like to extract one by one. For example, I would like to get the Employee's Social Security number, Identification Number (EIN), Name, address and ZIP code, and other fields.

If I convert the document to Excel directly, it is extracting the data in various rows and columns that is not desirable.

Is there any way that I can extract each field from the PDF file one by one and store it in database? A quick response is highly appreciated about this.

PDF Split

$
0
0
Hi Team,
I have requirement of splitting the PDF and download as single ZIP file.I am facing the issue like when i download the zip file the split pdf files are not available and the zip file is corrupt.Please help me as soon as possible.I fyou have better code snippet than this please send me this also.I have used .NET based zip class objects to create and add zip file and pdf file entries respectively.


parameter "inputPdfObject" is the input pdf file and it is a byte array object of the uploaded pdf.

MemoryStream memoryStream = new MemoryStream();
Aspose.Pdf.License license = new Aspose.Pdf.License();
                    license.SetLicense(@"..\App_Data\Aspose.Pdf.lic");
           
                    if (Aspose.Pdf.Document.IsLicensed)
                    {
                        Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(new MemoryStream(inputPdfObject));
                        var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true);
                        int pageCount = 1;
                        foreach (Page pdfPage in pdfDocument.Pages)
                        {
                            Aspose.Pdf.Document newDocument = new Aspose.Pdf.Document();
                            newDocument.Pages.Add(pdfPage);
                            ZipArchiveEntry zipFileEntry = archive.CreateEntry("Split" + pageCount + ".pdf");
                            using (Stream ZipFile = zipFileEntry.Open())
                            {
                                Stream splitStream = new MemoryStream();
                                newDocument.Save(splitStream, SaveFormat.Pdf);
                                byte[] splitPdf = ReadFully(splitStream);
                                ZipFile.Write(splitPdf, 0, splitPdf.Length);
                            }

                            pageCount++;
                        }
                        outputByteArray = memoryStream.ToArray();
                    }

                Response.Clear();
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment; filename=Split.zip");
                Response.BinaryWrite(byteArrayObject);

Rendering File issue : Checkbox is unchecked in the stamped document

$
0
0
Rendering File issue : Checkbox is unchecked in the stamped document.
Attached is the evidence of this issue. 

We are having updated aspose patch applied and still the issue exists.


Multithreaded JPEG to PDF conversion

$
0
0
Hi,

I have a problem with code performing a conversion from JPEG to PDF, when executing from multiple threads. The execution below takes ~ 6 sec to complete with 1 thread, but if the number of threads are increased to 10 it tasks ~ 122 sec. It seems that some internal resource prevents executing Pdf.save from multiple independent threads. Could we find out the reason of this behavior and if there are some solutions to it.

I would like to avoid synchronizing the calls

Using aspose.pdf-10.8.0.jar.

package test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.apache.log4j.Logger;

import aspose.pdf.ImageFileType;
import aspose.pdf.MarginInfo;
import aspose.pdf.Pdf;
import aspose.pdf.Section;

public class JPEGConversionIssue {

    static private Logger logger = Logger.getLogger(JPEGConversionIssue.class);

    public static void main(String[] args) throws Exception {
        long time = System.currentTimeMillis();
        ExecutorService executor = Executors.newFixedThreadPool(10); //try running in 1 thread
        for (int i = 0; i < 15; ++i) {
            executor.execute(new ThreadRunner());
        }
        executor.shutdown();
        executor.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS);
        System.out.println("transformation took: " + (System.currentTimeMillis() - time) + " ms");
    }

    public static class ThreadRunner implements Runnable {
        @Override
        public void run() {
            try {
                logger.info("convertion.start");
                FileInputStream fileInputStream = new FileInputStream("C:/Users/Denis/Desktop/image.jpeg");
                byte data[] = new byte[fileInputStream.available()];
                fileInputStream.read(data);
                fileInputStream.close();
                ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

                Pdf pdf = new Pdf();
                Section section = pdf.getSections().add();

                MarginInfo marginInfo = new MarginInfo();
                marginInfo.setTop(5);
                marginInfo.setRight(5);
                marginInfo.setBottom(5);
                marginInfo.setLeft(5);
                section.getPageInfo().setMargin(marginInfo);

                aspose.pdf.Image image = new aspose.pdf.Image(section);
                section.getParagraphs().add(image);

                int imageFileType = -1;
                imageFileType = ImageFileType.Jpeg;

                image.getImageInfo().setImageFileType(imageFileType);
                image.getImageInfo().setImageStream(inputStream);

                pdf.save(outputStream);

                FileOutputStream out = new FileOutputStream("out/" + Thread.currentThread().getName() + "." + System.currentTimeMillis() + ".pdf");
                out.write(outputStream.toByteArray());
                out.close();
                logger.info("convertion.done");
            } catch (Exception e) {
                e.printStackTrace();
                logger.error(e);
            }
        }
    }
}


Aspose Disposition

$
0
0
Hi Team,

What is the use of Aspose Disposition?

Iam trying to merge two PDF files coming in single data stream and send it back as single PDF?

Can I use Aspose Disposition functionality in this case?

Converting word document to PDF/A 3B (PDF v1.7) - overlapped text

$
0
0
Hi,

I am using last versions of Aspose.Words and Aspose.Pdf .NET to convert word documents to PDF/A 3B (v1.7) because of mandatory using of pades in european union since 1st July 2016.
At first I save the word document with aspose. words to PDF v1.5 then I convert it using Aspose.PDF to PDF v1.7 and then finaly convert it to PDF/A 3B

Code snippet:

  Public Function ConvertToPDFA(Bytes() As Byte) As Byte() Implements IConverterPDFA.ConvertToPDFA
    Dim InStream As New MemoryStream(Bytes)
    Dim OutStream As New MemoryStream()
    Dim Word As New Aspose.Words.Document(InStream)
    Dim PDFAOptions As New Aspose.Words.Saving.PdfSaveOptions()
    PDFAOptions.Compliance = Aspose.Words.Saving.PdfCompliance.Pdf15
    PDFAOptions.FontEmbeddingMode = Aspose.Words.Saving.PdfFontEmbeddingMode.EmbedAll
    Word.Save(OutStream, PDFAOptions)

    Dim OutStreamPDFA3 As New MemoryStream()
    Dim ms As New MemoryStream
    Dim pdf As New Aspose.Pdf.Document(OutStream)
    pdf.Convert(ms, Aspose.Pdf.PdfFormat.v_1_7, Aspose.Pdf.ConvertErrorAction.Delete)
    ms.Close()
    ms.Dispose()
    ms = New MemoryStream
    pdf.Convert(ms, Aspose.Pdf.PdfFormat.PDF_A_3B, Aspose.Pdf.ConvertErrorAction.Delete)
    pdf.Optimize()
    pdf.OptimizeResources()
    pdf.Save(OutStreamPDFA3)
    ms.Dispose()

    Return OutStreamPDFA3.ToArray
  End Function

The problem is that after last step is performed the text in document is overlapped.  Example document in attachment. I would really need this fixed before 1st July.

Thank Pilscom

HTML to PDF - Images are not displayed from Shared Floder

$
0
0
Hello,

I am using Aspose.PDF version 11.2 to convert HTML to PDF. In my HTML files I have some images loading from a shared network path.  

Images are loading properly inside the html file but they are not displayed inside PDF file. below is the code I am using:

            Dim pLicence As Aspose.Pdf.License = New Aspose.Pdf.License
            pLicence.SetLicense("Aspose.Total.lic")

            Dim basePath As String = Path.GetDirectoryName(FilePath)
            Dim htmloptions As New HtmlLoadOptions(basePath)

            ' Load HTML file
            Dim pdfDocument As New Document(FilePath, htmloptions)
            pdfDocument.PageInfo.Width = 597.6
            pdfDocument.PageInfo.Height = 842.4

            'get page collection
            Dim pageCollection As PageCollection = pdfDocument.Pages
            'get particular page
            For Each pdfPage As Page In pageCollection
                pdfPage.SetPageSize(597.6, 842.4)
            Next

            'Optimize the pdf file in order to decrease it's size
            Dim optimization As Aspose.Pdf.Document.OptimizationOptions = New Aspose.Pdf.Document.OptimizationOptions()
            optimization.LinkDuplcateStreams = True
            optimization.RemoveUnusedObjects = True
            optimization.RemoveUnusedStreams = True
            optimization.CompressImages = True
            pdfDocument.OptimizeResources(optimization)

            ' Save HTML file
            pdfDocument.Save(pdfFilePath, SaveFormat.Pdf)



How can I resolve the issue. I need a solution ASAP.

Thanks.

Change Advanced Print Setup options

$
0
0
Hello 

When I  use  this code 
 using (PdfFileSecurity sec = new PdfFileSecurity())
                    {
                        sec.BindPdf(stampedStream);
                        DocumentPrivilege documentPrivilege = DocumentPrivilege.ForbidAll;
                        documentPrivilege.AllowScreenReaders = true;
                        documentPrivilege.AllowPrint = true;
                        documentPrivilege.PrintAllowLevel = 2;
                        sec.EncryptFile(password, Guid.NewGuid().ToString(), documentPrivilege, KeySize.x128);
                        sec.Save(securedStream);
                    }

and after that I  save file to PDF.

When I open this file  in  Acrobat Reader  I see Print As Image is checked in Advanced Print Setup.

I want property Print As Image is unchecked.

How to  fix  this Problem ?








Indented TOC on an existing PDF Document

$
0
0
Hi,

Is it possible to create an indented Table of Contents to an existing PDF document?

I can create the following:-

 Table Of Contents

First page...................................1
Second page.............................. 2
Third page................................. 3
Fourth page................................4

With following code:-

// Load an existing PDF files
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document("C:/temp/Excel.pdf");

            // Get access to first page of PDF file
            Page tocPage = doc.Pages.Insert(1);

            // Create object to represent TOC information
            TocInfo tocInfo = new TocInfo();
            Aspose.Pdf.Text.TextFragment title = new Aspose.Pdf.Text.TextFragment("Table Of Contents");
            title.TextState.FontSize = 20;
            title.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold;

            // Set the title for TOC
            tocInfo.Title = title;
            tocPage.TocInfo = tocInfo;

            // Create string objects which will be used as TOC elements
            string[] titles = new string[4];
            titles[0] = "First page";
            titles[1] = "Second page";
            titles[2] = "Third page";
            titles[3] = "Fourth page";

for (int i = 0; i < 4; i++)
            {
                // Create Heading object
                Aspose.Pdf.Heading heading2 = new Aspose.Pdf.Heading(1);
                Aspose.Pdf.Text.TextSegment segment2 = new Aspose.Pdf.Text.TextSegment();
                heading2.TocPage = tocPage;
                heading2.Segments.Add(segment2);

                // Specify the destination page for heading object
                heading2.DestinationPage = doc.Pages[i + 2];

                // Destination page
                heading2.Top = doc.Pages[i + 2].Rect.Height;

                // Destination coordinate
                segment2.Text = titles[i];
                                
                // Add heading to page containing TOC
                tocPage.Paragraphs.Add(heading2);
            }

// Save the updated document
            doc.Save("C:/temp/TOC_Output2.pdf");  


What I want to do is add an indented TOC to an existing PDF document, something like the below:-

Table of Contents

Heading1......................................................1
       Heading1 Sub .......................................1
       Heading2 Sub .......................................2
Heading3......................................................3
     Heading3 Sub..........................................4
Heading4.......................................................5

Is this only possible when generating a new PDF (using the PDF Generator) and not adding a TOC to an existing PDF?


Thanks

Jon.

Adobe Versioning Issue with Aspose PDF?

$
0
0
Hello!

I'm wondering if there's a known issue with older versions of Adobe Reader behaving properly with the Aspose PDF dll?

The client I'm working with has Adobe Reader 10, for my testing I've been using Adobe Reader DC which is a newer version of the software. They've told me that some of their documents are opening very slowly (taking 2-4 mins to open) whereas others aren't opening at all.

When I test out one of the ones that's not opening at all on my machine, it opens up after a few seconds and fills in the merge field data for some of the fields (we also don't have all of the merge fields in place that they have, they have some that are specific to them).

Which leads me to believe that it's either a problem with with the way the merge field data is being handled for one of the fields I'm not filling in, or it's a matter of the older version of Adobe and Aspose not playing nice with each other.

My code is below:


'Do PDF merge

' Load XFA form
Dim doc As Aspose.Pdf.Document = New Aspose.Pdf.Document(sTemplateDir & sDocName)

' Get names of XFA form fields
Dim names As String() = doc.Form.XFA.FieldNames

'Get names of form fields
Dim fields As Aspose.Pdf.InteractiveFeatures.Forms.Field() = doc.Form.Fields


Dim sField As String

Dim field As Aspose.Pdf.InteractiveFeatures.Forms.Field

If fields.Length > 0 Then
For Each field In fields
'Get name of field
sField = field.FullName

'If the merge field isn't valid then we'll just leave it and assume its a fill-in
If nMergeCol.Contains(sField) And Not IsNothing(sField) Then
field.Value = nMergeCol.Item(sField)
End If
Next

Else
' Set field values
Dim sName As String

For Each sName In names
'Parse the XFA name
Dim sCount As Integer = sName.Length


Dim period As Integer = InStrRev(sName, ".")

Dim newName As String = sName.Substring(period)

Dim sMergeName As String = newName.Remove(newName.Length - 3, 3)

If nMergeCol.Contains(sMergeName) Then
doc.Form.XFA(sName) = nMergeCol.Item(sMergeName)
End If
Next
End If

On a side note, the XFA part of the code seems to be working fine from what the client has told me, the issue is just with the part that goes through the regular document fields.

Any assistance would be appreciated.

Thanks!

Issues with missing characters and font handling

$
0
0
We noticed some issues with characters which don't exist in a specific font.

If there is a character which is not contained by any installed font, the character will be replaced by a square. Also if a character doesn't exist for a specific font, but there is another font installed which does contain this character, this character is taken from this font.

For example if we create a PDF file using "Times New Roman" and add the text "Test". The PDF document will contain the text with the correct font. However if we add the text "Test テスト", the fonts "MSGothic" and "ArialUnicodeMS" will be used instead (according to the document properties from Acrobat Reader).

We need a way to retrieve the following information when adding text to the document:
  • Is there an unresolvable character in the text? (no font available)
  • Are characters in the text which require a different font?
    • Which fonts are required/used?

The minimal setup code ("Test" is obviously not Times):
static void test(String outfile)
{
    Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
    Aspose.Pdf.Page page = doc.Pages.Add();
    Aspose.Pdf.Text.TextFragment fragment = new Aspose.Pdf.Text.TextFragment("Test テスト 蟗");
    fragment.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Times-New-Roman");
    fragment.TextState.FontSize = 40;
    Aspose.Pdf.Text.TextBuilder tb = new Aspose.Pdf.Text.TextBuilder(page);
    tb.AppendText(fragment);
    doc.Save(outfile);
}

Aspose Email Component

$
0
0
We have a requirement to download the emails from the mail Inbox, and convert the email body to PDF. Each email unique reference ID is required to be stored in back-end. The process is required to download only the emails that are not stored to back-end. Is there any option available from Aspose to get the unique ID for each email from Inbox. 

Formatting to PDF from HTML takes forever and timing out in our application.

$
0
0
Hi Support Team,

We are using version Aspose 9.1 

We have  tried Aspose.Pdf and Aspose.Words  to convert our HTML to PDF. 
But, it takes forever and times out in our application.  We had the time out set for over 40 minutes to review but it was still processing and timed out.
Out Html contains tables, images and quite a lot of formatting. Attached sample html to give you an idea on the format and, which we were trying to convert to PDF.

Also, is there any known issues with HTML tags which might cause issue when converting/ formatting  to PDF?  


Thanks,

Mixed font styling on a single line

$
0
0
I am working with the trial version of the Aspose PDF component and am trying to apply different styling to the text within a TextFragment component.

So as an example:

Name: Someones Full Name

As shown is how I'd like the text to appear. The category "Name" would be in bold text while the actual persons name would be in regular font.

So far I haven't been able to figure a way to do this except to put the "Name" text in a TextFragment using a bold font and then creating another TextFragment with separate styling. I then move the second TextFragment to align it to the left of the first one using its Position attribute.

While I've gotten this to work, it isn't a good solution because since the content is being generated dynamically; any lines added above this can potentially offset the positioning and throw things off.

Is there another way to have mixed styling of text on a single line???

Please Help!


URGENT: Image placement on the form is not consistent across browsers

$
0
0
Hi,

We recently decided to go ahead and purchase the license for Aspose.PDF and everything appeared to be working just fine until recently noticing that one of the images on a form seems to move to different positions depending on the browser.

More specifically, we've noted the issue between IE 11 and Chrome. I have a TextFragment containing the following:

Signature: __________________________________________

Our client wanted the form to include someones e-signature on the signature line so to do this we acquired a png image from them containing the signature and then placed it on the form using code resembling this:

int lowerLeftX = 240;
int lowerLeftY = 325; 
int upperRightX = 340; 
int upperRightY = 278; 

var imageName = @"C:\Sandbox\AsposePDF\esignature.png";

 //get the page where image needs to be added
Aspose.Pdf.Page page = pdfDocument.Pages[1];
FileStream imageStream = new FileStream(imageName, FileMode.Open);
page.Resources.Images.Add(imageStream);

//using GSave operator: this operator saves current graphics state
page.Contents.Add(new Operator.GSave());

//create Rectangle and Matrix objects
Aspose.Pdf.Rectangle rectangle = new Aspose.Pdf.Rectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY);
Aspose.Pdf.DOM.Matrix matrix = new Aspose.Pdf.DOM.Matrix(new double[] { rectangle.URX - rectangle.LLX, 0, 0, rectangle.URY - rectangle.LLY, rectangle.LLX, rectangle.LLY });

//using ConcatenateMatrix (concatenate matrix) operator: defines how image must be placed
page.Contents.Add(new Operator.ConcatenateMatrix(matrix));
 XImage ximage = page.Resources.Images[page.Resources.Images.Count];

 //using Do operator: this operator draws image
page.Contents.Add(new Operator.Do(ximage.Name));

//using GRestore operator: this operator restores graphics state
page.Contents.Add(new Operator.GRestore());

imageStream.Close();
imageStream.Dispose();

During testing, I was able to set the image perfectly aligned on top of the signature line by affirming the result in IE 11. But after deploying the solution out someone discovered that the image was positioned approximately 100 or more pixels above the line in Chrome.

I am accustomed to discrepancies within browsers; especially with the diverse interpretation for pixel widths. So although I wouldn't have imagined this issue to be attributed to browser rendering as much as a feature within the Aspose API; even so, we are looking at more than a couple of pixel differences that we could otherwise accept.

Is there a more appropriate way to position the image on the TextFragment line that we should be using? How can we overcome this huge discrepancy?

Please help!

=========================
          RECENT UPDATE
=========================
In the process of troubleshooting this issue we've found some new information. Apparently the issue is only prevalent after deployment to our Azure Cloud Server. Locally the graphical location is consistent between Chrome and IE after rendering. 

Hopefully this new piece of information will provide some insight as to why this is occurring. Why the anomaly exists between browser platform only after deployment is still puzzling though. 



Viewing all 1038 articles
Browse latest View live