Coder Social home page Coder Social logo

dspdf's Introduction

Document Solutions for PDF (DsPdf)

Overview

Document Solutions for PDF (aka DsPdf) is a .NET class library written in C#, providing an API that allows you to create PDF files from scratch and to load, analyze and modify existing PDF documents.

DsPdf is compatible with .NET 7, .NET 6, .NET 5, .NET Core 3.x and 2.x, .NET Standard 2.x, .NET Framework 4.6.1 or higher, with all features fully supported on all operating systems that support .NET.

DsPdf and supporting packages are available on NuGet.org.

To use DsPdf in an application, you need to reference (install) just the GrapeCity.Documents.Pdf package. It will pull in the required infrastructure packages.

To render HTML content, install the GrapeCity.Documents.Html (aka DsHtml) package. It allows you to save whole HTML pages as PDFs, or include HTML fragments into PDFs along with other content.

To render barcodes, install the GrapeCity.Documents.Barcode (aka DsBarcode) package. It provides extension methods that allow you to add barcodes to PDFs.

On a Windows system, you can optionally install GrapeCity.Documents.Common.Windows. It provides support for font linking specified in the Windows registry, and access to native Windows imaging APIs.

What is here

This repository contains example projects that demonstrate basic and advanced features of DsPdf. The samples' code includes extensive comments that will help you learn DsPdf and quickly get up to speed using it.

Licensing

To use DsPdf in a production environment, you need a valid license, contact [email protected] for details.

When used without a license, DsPdf has the following limitations:

  • A header saying that an unlicensed version was used is added at the top of all pages in the generated PDFs.
  • When loading PDFs, only up to 5 first pages are loaded.

Resources

dspdf's People

Contributors

dima-y avatar alexboyang avatar

Stargazers

 avatar Robi Hahn avatar sunriseyuen avatar  avatar Roman Shapiro avatar Sergey Todyshev avatar Fan avatar Kuni avatar

Watchers

James Cloos avatar Zhang Wenqing avatar  avatar JackShang avatar  avatar  avatar

Forkers

seagen

dspdf's Issues

DocAttachments sample doesnt work when EmbeddedFileStream is created through EmbeddedFileStream.FromBytes

Hello,
I've slightly modified DocAttachment sample so it uses EmbeddedFileStream.FromBytes(instead of original EmbeddedFileStream.FromFile).
So full modified sample code is:

using System;
using System.IO;
using System.Linq;
using System.Text;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Drawing;

namespace GcPdfWeb.Samples.Basics
{
    // Shows how to attach files to a PDF document.
    // See also the FileAttachments sample that demonstrates file attachment annotations,
    // which are attached to a specific location on a page.
#if !DIODOCS_V1
#endif
    public class DocAttachments
    {
        public void CreatePDF(Stream stream)
        {
            var doc = new GcPdfDocument();
            var page = doc.NewPage();

            string[] files = new string[]
            {
                "tudor.jpg",
                "sea.jpg",
                "puffins.jpg",
                "lavender.jpg",
                "skye.jpg",
                "fiord.jpg",
                "out.jpg"
            };
            var sb = new StringBuilder();
            foreach (var fn in files)
                sb.AppendLine(fn);
            Common.Util.AddNote(
                "Several images from the sample's Resources/Images folder are attached to this document:\n\n" +
                sb.ToString(), page);
            foreach (string fn in files)
            {
                string file = Path.Combine("Resources", "Images", fn);
		var bytes = File.ReadAllBytes(file);
                FileSpecification fspec = FileSpecification.FromEmbeddedFile(EmbeddedFileStream.FromBytes(doc, bytes));
                doc.EmbeddedFiles.Add(file, fspec);
            }
            // Done:
            doc.Save(stream);
        }
    }
}

Now it generates pdf without any attachment(while original method worked fine):
image

What do I do incorrectly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.