Invalid ColorSpace error in PDF files in Acrobat or Reader

オープン
#1,601 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
angular, javascript
領域
web-dev

調査の方向性

まず、指定された webpack 構成と PDF/A-3a サブセットを使用して、提供された pdfkit 0.16.0 のサンプルを再現し、生成されたファイルを Adobe Reader で開きます。サブセットを削除した場合に生成されるファイルと比較します。生成された PDF/A-3a ファイルが報告された Invalid ColorSpace エラーなしで開けば完了です。

索引モデルが issue の本文から書いたものです。

説明

Bug Report

Invalid ColorSpace error in PDF files in Acrobat or Reader

Description of the problem

There is an error displayed in Adobe Reader 'Invalid ColorSpace error in PDF files in Acrobat or Reader' while opening the PDF/A-3a file generated in PDFKit. When I remove the subset of PDF/A-3a Adobe doesn't throw any errors and opens the file correctly.

I'm working in latest angular version and latest pdfkit.

Code sample


import blobStream from 'blob-stream';
import pdfkit from 'pdfkit';


 async createPdf(htmlDoct: string) {
    const doc = new pdfkit({
      pdfVersion: '1.7',
      subset: 'PDF/A-3a',
      tagged: true,
      displayTitle: true,
      size: 'A4',
      bufferPages: true,
      margin: 30,
    });
   // draw some text
   doc.fontSize(25).text('Here is some vector graphics...', 100, 80);

   // some vector graphics
   doc
     .save()
     .moveTo(100, 150)
     .lineTo(100, 250)
     .lineTo(200, 250)
     .fill('#FF3300');
 
   doc.circle(280, 200, 50).fill('#6600FF');
 
   // an SVG path
   doc
     .scale(0.6)
     .translate(470, 130)
     .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
     .fill('red', 'even-odd')
     .restore();
 
   doc.save();
   // a gradient fill
   var gradient = doc
     .linearGradient(100, 300, 200, 300)
     .stop(0, 'green')
     .stop(0.5, 'red')
     .stop(1, 'green');
   doc.rect(100, 300, 100, 100).fill(gradient);
   let stream = doc.pipe(blobStream());

   // stroke & fill uncolored tiling pattern
 
   var stripe45d = doc.pattern(
     [1, 1, 4, 4],
     3,
     3,
     '1 w 0 1 m 4 5 l s 2 0 m 5 3 l s'
   );
   doc.circle(280, 350, 50).fill([stripe45d, 'blue']);
 
   doc
     .rect(380, 300, 100, 100)
     .fillColor('lime')
     .strokeColor([stripe45d, 'orange'])
     .lineWidth(5)
     .fillAndStroke();
   doc.restore();
 
   // and some justified text wrapped into columns
   doc
     .text('And here is some wrapped text...', 100, 450)
     .font('Times-Roman', 13)
     .moveDown()
     .text('lorem', {
       width: 412,
       align: 'justify',
       indent: 30,
       columns: 2,
       height: 300,
       ellipsis: true
     });
 
    doc.end();
    stream.on('finish', () => {
      window.open(stream.toBlobURL('application/pdf'));
    });
  }

my webpack config export file :



     module.exports = {
  plugins: [
    new webpack.ProvidePlugin({
      Buffer: ['buffer', 'Buffer'],
      process: 'process/browser',
    }),
    new webpack.DefinePlugin({
      output: {
        path: path.resolve(__dirname, '/dist/apps/' + project),
      },
    }),
  ],
  resolve: {
    symlinks: false,
    alias: {
      // maps fs to a virtual one allowing to register file content dynamically
      fs: __dirname +  '/virtual-fs.js'
    },
    fallback: {
      // crypto module is not necessary at browser
      crypto: false,
      // fallbacks for native node libraries
      buffer: require.resolve('buffer/'),
      stream: require.resolve('readable-stream'),
      zlib: require.resolve('browserify-zlib'),
      util: require.resolve('util/'),
      assert: require.resolve('assert/'),
      fs: require.resolve('fs'),
    },
  },

  module: {
    rules: [
      { test: /\.afm$/, type: 'asset/source' }, 
      { test: /\.icc$/, type: 'asset/source' },  
      { test: /\.png$/, type: 'asset/source' },
      {
        test: /src[/\\]static-assets/,
        type: 'asset/inline',
        generator: {
          dataUrl: (content) => {
            return content.toString('base64');
          },
        },
      },
      // load binary files inside lazy-assets folder as an URL
      {
        test: /src[/\\]lazy-assets/,
        type: 'asset/resource',
      },
    ],
  },
};

Your environment

  • pdfkit version: 0.16.0
  • Node version:
  • Browser version (if applicable):
  • Operating System:
主要言語
JavaScript
スター
10.7k
フォーク
1.2k
平均マージ
21時間 41分
マージ済み PR(30日)
27

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

foliojs/pdfkit のほかの issue

foliojs/pdfkit の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。